package test;

import org.apache.http.entity.ContentType;

import java.io.*;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.Date;

public class main {

    public static void main(String[] args) {
        /**
         * ???????????????????
         */
        try {
//            RandomAccessFile raf = new RandomAccessFile("E:\\Desktop\\????????\\data\\????????????7776640????.txt", "rw");
            RandomAccessFile raf = new RandomAccessFile("E:\\Desktop\\????????\\data\\111.txt", "rw");
            String line;

            int i = 0;
            while ((line = raf.readLine()) != null) {
                line = new String(line.getBytes("ISO-8859-1"), "gbk");
                if (line.contains("????????")) {
                    raf.seek(raf.getFilePointer() - line.getBytes().length - 1);    //1??/n??????????gbk   5/utf-8
                    raf.write((String.format("%" + (line.getBytes().length + 1) + "s", "\n")).getBytes("utf-8"));
                }
                System.out.println(i++);
            }
            raf.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        System.out.println("????????");
        System.out.println(String.format("%8s", "-"));


        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        sdf.format(new Date());

    }
}
